package com.hyh.sso.po;

import com.hyh.utils.code.MD5;
import com.hyh.utils.common.StringUtils;

import java.util.Calendar;

/**
 * 用户Token对象
 *
 * @Author: heyuhua
 * @Date: 2021/1/8 17:07
 */
public class UserToken {

    /**
     * token
     */
    private String token;

    /**
     * 过期时间
     */
    private String expireTime;

    public UserToken(String token, String expireTime) {
        this.token = token;
        this.expireTime = expireTime;
    }

    public UserToken() {

    }

    public static UserToken getUserToken() {
        Calendar nowTime = Calendar.getInstance();
        nowTime.add(Calendar.MINUTE, 30);
        return new UserToken(MD5.getMD5String(StringUtils.ranStr(32)), String.valueOf(nowTime.getTimeInMillis()));
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(String expireTime) {
        this.expireTime = expireTime;
    }

    /**
     * 生成Token
     */
    private String generateToken() {
        return MD5.getMD5String(StringUtils.ranStr(32));
    }
}
